import os

from flask import Flask
from src.main.controller.SystemController import system_blueprint
from src.main.controller.StudentController import student_blueprint
from src.main.util.ApplicationConfig import ApplicationConfig

app = Flask(__name__)

# 注册系统相关路由
app.register_blueprint(system_blueprint, url_prefix='/system')
# 注册学生相关路由
app.register_blueprint(student_blueprint, url_prefix='/student')

if __name__ == '__main__':
    # 初始化应用配置
    app_config = ApplicationConfig()
    # 获取当前文件所在目录的父目录，即项目根目录
    ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
    app_config.write_root_dir_to_config(ROOT_DIR)
    # 启动
    app.run(debug=True, port=8888)
